package test;

import comment.Comment;

/**
 *create by tbj
 */
public class MyQuick_one {
	private static int partition(int[] a,int l,int r){
		int v=a[l];
		int j=l;
		for(int i=l;i<=r;i++){
			if(a[i]<v){
				Comment.swapIntArr(a, i, j+1);
				j++;
			}
		}
		Comment.swapIntArr(a, l, j);
		return j;
	}
	private static void _sort(int[] a,int l,int r){
		if(l >= r){
			return;
		}
		int p=partition(a,l,r);
		_sort(a, l, p-1);
		_sort(a, p+1, r);
	}
	public static void sort(int[] a){
		int n=a.length;
		_sort(a,0,n-1);
	}
	public static void main(String[] args) {
		int[] a=Comment.getSortIntArr();
		MyQuick_one.sort(a);
		for (int i : a) {
			System.out.print(i+" ");
		}
	}
}
